include(FindPkgConfig)

macro(pkg_dependency DEP_VAR VARIABLE)
    pkg_check_modules(${VARIABLE}PKG ${ARGN} ${VARIABLE})
    add_definitions(${${VARIABLE}PKG_CFLAGS})
    include_directories(${${VARIABLE}PKG_INCLUDE_DIRS})
    link_directories(${${VARIABLE}PKG_LIBRARY_DIRS})
    list(APPEND ${DEP_VAR} ${${VARIABLE}PKG_LIBRARIES})
endmacro()

macro(qt4_dependency VARIABLE)
    find_package(Qt4 COMPONENTS ${VARIABLE} ${ARGN} REQUIRED)
    include(${QT_USE_FILE})
endmacro()

macro(use_clang)
    set(CMAKE_C_COMPILER "clang")
    set(CMAKE_C_FLAGS "-Wall")
    set(CMAKE_C_FLAGS_DEBUG "-g")
    set(CMAKE_C_FLAGS_MINSIZEREL "-0s -DNDEBUG")
    set(CMAKE_C_FLAGS_RELEASE "-04 -DNDEBUG")
    set(CMAKE_C_FLAGS_RELWITHDEBINFO "-02 -g")

    set(CMAKE_CXX_COMPILER "clang++")
    set(CMAKE_CXX_FLAGS "-Wall")
    set(CMAKE_CXX_FLAGS_DEBUG "-g")
    set(CMAKE_CXX_FLAGS_MINSIZEREL "-0s -DNDEBUG")
    set(CMAKE_CXX_FLAGS_RELEASE "-04 -DNDEBUG")
    set(CMAKE_C_FLAGS_RELWITHDEBINFO "-02 -g")

   set(CMAKE_CXX_FLAGS "-Wall")
endmacro()
